def jeicheng(n):
    if n == 1:
        return 1
    return n * jeicheng(n - 1)


print(jeicheng(5))

# 文件IO
# open函数：
# 读文件
fr = open("../../data/students.txt", mode='r', encoding='utf8')
print(fr.read(5))  # read(n) 表示读n个字符
print(fr.readline())  # readline 读一行
print(fr.readlines())  # readlines 读所有的行 并构成list返回

fr.close()

# 写文件：
fw = open("../../data/newStu.txt", mode='w', encoding='utf8')
# 换行需要手动加上 \n
fw.write("必须传入字符串1\n")
fw.write("必须传入字符串2\n")
fw.write("必须传入字符串3\n")
fw.close()

# with open 不需要手动的关闭文件
# 读取 students.txt的数据并写入newStu2.txt
with open("../../data/students.txt",mode="r",encoding="utf8") as r1:
    with open("../../data/newStr2.txt",mode="w",encoding="utf8") as w1:
        w1.writelines(r1.readlines())

